package com.wanxi;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class RemoveNumber {
    public static void main(String[] args) {
        List list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            list.add(i);
        }
        System.out.println(list);

        Iterator iterator = list.iterator();

//        while (iterator.hasNext()) {
//           if (iterator.next().equals(2)){
//               iterator.remove();
//           }
//        }

        while (iterator.hasNext()){


            iterator.remove();
        }



        System.out.println(list);


    }
}
